package com.scsj.supermarket.presenter;

import android.util.Log;

import com.orhanobut.logger.Logger;
import com.scsj.supermarket.base.QueryTradeDetailBase;
import com.scsj.supermarket.base.RechargeBase;
import com.scsj.supermarket.bean.RechargeBean;
import com.scsj.supermarket.bean.RefundOrderBean;
import com.scsj.supermarket.model.QueryTradeDetailModel;
import com.scsj.supermarket.model.RechargeModel;

import dkmvp.mvp.BasePresenter;
import dkmvp.net.ResponseCallback;
import okhttp3.RequestBody;

/**
 * 充值
 */

public class RechargePresenter extends BasePresenter implements RechargeBase.IPresenter {

    private RechargeBase.IView mView;
    private RechargeBase.IModel mModel;

    public RechargePresenter(RechargeBase.IView mView) {
        this.mView = mView;
        mModel = new RechargeModel();
    }

    @Override
    public void deliverData(RequestBody requestBody) {

        addSubscription(mModel.getData(requestBody, new ResponseCallback<RechargeBean>() {
            @Override
            public void onSuccess(RechargeBean result) {

                if (result.getStatusCode()== 200) {
                    mView.showSuccessMsg("获取成功",result);
                    Logger.e("获取成功" + result.toString());
                } else {
                    mView.showErrorMsg(result.getMsg());
                    Logger.e("未成功" + result.toString());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showErrorMsg(msg);
                Log.e("失败", msg + "");
            }
        }));

    }
}
